home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / iface.h < prev    next >
C/C++ Source or Header  |  1994-06-04  |  6KB  |  160 lines

  1. #ifndef    _IFACE_H
  2. #define    _IFACE_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef _PROC_H
  13. #include "proc.h"
  14. #endif
  15.  
  16. /* Interface encapsulation mode table entry. An array of these structures
  17.  * are initialized in config.c with all of the information necessary
  18.  * to attach a device.
  19.  */
  20. #ifdef __GNUC__
  21. struct iface;            /* forward declaration for gcc */
  22. #endif
  23.  
  24. #ifdef UNIX
  25. #ifndef send
  26. /* ugly hack to avoid both libc collisions and jnos misconnections */
  27. #include "socket.h"
  28. #endif
  29. #endif
  30.  
  31. struct iftype {
  32.     char *name;        /* Name of encapsulation technique */
  33.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  34.                 /* Routine to send an IP datagram */
  35.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  36.                 /* Routine to send link packet */
  37.     char *(*format) __ARGS((char *,char *));
  38.                 /* Function that formats addresses */
  39.     int (*scan) __ARGS((char *,char *));
  40.                 /* Reverse of format */
  41.     int type;        /* Type field for network process */
  42.     int hwalen;        /* Length of hardware address, if any */
  43. };
  44. #define    NULLIFT    (struct iftype *)0
  45. extern struct iftype Iftypes[];
  46.  
  47.  
  48. /* Interface control structure */
  49. struct iface {
  50.     struct iface *next;    /* Linked list pointer */
  51.     char *name;        /* Ascii string with interface name */
  52.     char *descr;    /* Description of interface */
  53.  
  54.     int32 addr;        /* IP address */
  55.     int32 broadcast;    /* Broadcast address */
  56.     int32 netmask;        /* Network mask */
  57.  
  58.     int16 mtu;        /* Maximum transmission unit size */
  59.     int16 paclen;   /* AX.25 paclen, if applicable */
  60.  
  61.     int32 flags;        /* Configuration flags */
  62. #define DATAGRAM_MODE   0   /* Send datagrams in raw link frames */
  63. #define    CONNECT_MODE    1    /* Send datagrams in connected mode */
  64. #define IS_NR_IFACE     2   /* Activated for NET/ROM - WG7J */
  65. #define NR_VERBOSE      4   /* NET/ROM broadcast is verbose - WG7J */
  66. #define IS_CONV_IFACE   8   /* Activated for conference call access - WG7J */
  67. #define AX25_BEACON     16  /* Broadcast AX.25 beacons */
  68. #define MAIL_BEACON     32  /* Send MAIL beacons */
  69. #define HIDE_PORT       64  /* Don't show port in mbox P command */
  70. #define AX25_DIGI       128 /* Allow digipeating */
  71. #define ARP_EAVESDROP   256 /* Listen to ARP replies */
  72. #define ARP_KEEPALIVE   512 /* Keep arp entries alive after timeout */
  73. #define LOG_AXHEARD    1024 /* Do ax.25 heard logging on this interface */
  74. #define LOG_IPHEARD    2048 /* Do IP heard logging on this interface */
  75. #define NO_AX25        4096 /* No ax.25 mbox connections on this port */
  76. #define BBS_ONLY       8192 /* BBS's only in mbox via this port */
  77. #define USERS_ONLY     16384 /* Users only on this port */
  78. #define SYSOP_ONLY     32768 /* Sysops only on this port */
  79.  
  80.     int quality;            /* Netrom interface quality */
  81.  
  82.     int16 trace;        /* Trace flags */
  83. #define    IF_TRACE_OUT    0x01    /* Output packets */
  84. #define    IF_TRACE_IN    0x10    /* Packets to me except broadcast */
  85. #define    IF_TRACE_ASCII    0x100    /* Dump packets in ascii */
  86. #define    IF_TRACE_HEX    0x200    /* Dump packets in hex/ascii */
  87. #define    IF_TRACE_NOBC    0x1000    /* Suppress broadcasts */
  88. #define    IF_TRACE_RAW    0x2000    /* Raw dump, if supported */
  89.     char *trfile;        /* Trace file name, if any */
  90.     FILE *trfp;        /* Stream to trace to */
  91.  
  92.     struct iface *forw;    /* Forwarding interface for output, if rx only */
  93.  
  94.     struct proc *rxproc;    /* Receiver process, if any */
  95.     struct proc *txproc;    /* Transmitter process, if any */
  96.     struct proc *supv;    /* Supervisory process, if any */
  97.  
  98.     /* Device dependant */
  99.     int dev;        /* Subdevice number to pass to send */
  100.                 /* To device -- control */
  101.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  102.                 /* From device -- when status changes */
  103.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  104.                 /* Call before detaching */
  105.     int (*stop) __ARGS((struct iface *));
  106.     char *hwaddr;        /* Device hardware address, if any */
  107.  
  108.     /* Encapsulation dependant */
  109.     void *edv;        /* Pointer to protocol extension block, if any */
  110.     int type;        /* Link header type for phdr */
  111.     int xdev;        /* Associated Slip or Nrs channel, if any */
  112.     int port;        /* Sub port for multy port kiss */
  113.     struct iftype *iftype;    /* Pointer to appropriate iftype entry */
  114.  
  115.             /* Encapsulate an IP datagram */
  116.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  117.             /* Encapsulate any link packet */
  118.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  119.             /* Send raw packet */
  120.     int (*raw)        __ARGS((struct iface *,struct mbuf *));
  121.             /* Display status */
  122.     void (*show)        __ARGS((struct iface *));
  123.  
  124.     int (*discard)        __ARGS((struct iface *,struct mbuf *));
  125.     int (*echo)        __ARGS((struct iface *,struct mbuf *));
  126.  
  127.     /* Counters */
  128.     int32 ipsndcnt;     /* IP datagrams sent */
  129.     int32 rawsndcnt;    /* Raw packets sent */
  130.     int32 iprecvcnt;    /* IP datagrams received */
  131.     int32 rawrecvcnt;    /* Raw packets received */
  132.     int32 lastsent;        /* Clock time of last send */
  133.     int32 lastrecv;        /* Clock time of last receive */
  134. };
  135. #define    NULLIF    (struct iface *)0
  136. extern struct iface *Ifaces;    /* Head of interface list */
  137. extern struct iface  Loopback;    /* Optional loopback interface */
  138. extern struct iface  Encap;    /* IP-in-IP pseudo interface */
  139.  
  140. /* Header put on front of each packet in input queue */
  141. struct phdr {
  142.     struct iface *iface;
  143.     unsigned short type;    /* Use pktdrvr "class" values */
  144. };
  145. extern char Noipaddr[];
  146. extern struct mbuf *Hopper;
  147.  
  148. /* In iface.c: */
  149. struct iface *if_lookup __ARGS((char *name));
  150. struct iface *ismyaddr __ARGS((int32 addr));
  151. int if_detach __ARGS((struct iface *ifp));
  152. int setencap __ARGS((struct iface *ifp,char *mode));
  153. char *if_name __ARGS((struct iface *ifp,char *comment));
  154. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  155.  
  156. /* In config.c: */
  157. int net_route __ARGS((struct iface *ifp,int type,struct mbuf *bp));
  158.  
  159. #endif    /* _IFACE_H */
  160.